package com.bs.blogspace.mapper;

import com.bs.blogspace.pojo.AddSpace;
import com.bs.blogspace.pojo.Space;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SpaceMapper {
    
    //  插入空间信息
    @Insert("insert into space(space_name,space_image,phone,user_name,space_description,text,image,create_time,update_time)" +
            "VALUES (#{spaceName},#{spaceImage},#{phone},#{userName},#{spaceDescription},#{text},#{image},#{createTime},#{updateTime})")
    void insert(Space space);

    //获取所有空间
    @Select("select * from space")
    List<Space> getAll();
    //获取单个空间
    @Select("select * from space where space_id=#{spaceid}")
    Space getBySpace(String spaceid);

    /*查看指定用户创建的空间*/
    @Select("select space_id,space_name from space where phone=#{phone}")
    List<Space> queryUserSpace(String phone);

     // 更新加入指定空间的人数
    @Update("update `space` set space_people =#{spacePeople} where space_id=#{spaceId}")
    int updateSpacePeople(Space space);




}
